package com.hjm.project.accounts.virtualAccountDetail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.accounts.virtualAccountDetail.domain.VirtualAccountDetail;
import com.hjm.project.accounts.virtualAccountDetail.service.IVirtualAccountDetailService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 虚拟账户记录Controller
 * 
 * @author maker-platform
 * @date 2022-03-16
 */
@Controller
@RequestMapping("/accounts/virtualAccountDetail")
public class VirtualAccountDetailController extends BaseController {
    private String prefix = "accounts/virtualAccountDetail";

    @Resource
    private IVirtualAccountDetailService virtualAccountDetailService;

    @RequiresPermissions("accounts:virtualAccountDetail:view")
    @GetMapping()
    public String virtualAccountDetail() {
        return prefix + "/virtualAccountDetail";
    }

    /**
     * 查询虚拟账户记录列表
     */
    @RequiresPermissions("accounts:virtualAccountDetail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(VirtualAccountDetail virtualAccountDetail) {
        startPage();
        List<VirtualAccountDetail> list = virtualAccountDetailService.selectVirtualAccountDetailList(virtualAccountDetail);
        return getDataTable(list);
    }

    /**
     * 导出虚拟账户记录列表
     */
    @RequiresPermissions("accounts:virtualAccountDetail:export")
    @Log(title = "虚拟账户记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(VirtualAccountDetail virtualAccountDetail) {
        List<VirtualAccountDetail> list = virtualAccountDetailService.selectVirtualAccountDetailList(virtualAccountDetail);
        ExcelUtil<VirtualAccountDetail> util = new ExcelUtil<VirtualAccountDetail>(VirtualAccountDetail.class);
        return util.exportExcel(list, "virtualAccountDetail");
    }

    /**
     * 新增虚拟账户记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存虚拟账户记录
     */
    @RequiresPermissions("accounts:virtualAccountDetail:add")
    @Log(title = "虚拟账户记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(VirtualAccountDetail virtualAccountDetail) {
        return toAjax(virtualAccountDetailService.insertVirtualAccountDetail(virtualAccountDetail));
    }

    /**
     * 修改虚拟账户记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
        VirtualAccountDetail virtualAccountDetail = virtualAccountDetailService.selectVirtualAccountDetailById(id);
        mmap.put("virtualAccountDetail", virtualAccountDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存虚拟账户记录
     */
    @RequiresPermissions("accounts:virtualAccountDetail:edit")
    @Log(title = "虚拟账户记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(VirtualAccountDetail virtualAccountDetail) {
        return toAjax(virtualAccountDetailService.updateVirtualAccountDetail(virtualAccountDetail));
    }

    /**
     * 删除虚拟账户记录
     */
    @RequiresPermissions("accounts:virtualAccountDetail:remove")
    @Log(title = "虚拟账户记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(virtualAccountDetailService.deleteVirtualAccountDetailByIds(ids));
    }
}
